const http = require('http');
// const { json } = require('node:stream/consumers');

let user = { id: 1, name: 'Jimmy' };
const app = new http.createServer((req, res) => {
  res.setHeader('Access-Control-Allow-Origin', '*');
  let url = req.url;
  if (url === '/base') {
    res.end(JSON.stringify(user));
  } else if (url === '/about?user=Jimmy') {
    res.end('JimmyMsg');
  } else if (url === '/detail?msg=JimmyMsg') {
    res.end('msgmsgmsg');
  }
  //   res.end('hello world');
});

app.listen(666);
